class Node:
    def __init__(self,data):
        self.data = data
        self.next = None

def reverseList(head):
    if not head or head.next == None:
        return head
    T = reverseList(head.next)
    t = head.next
    t.next = head
    head.next = None
    return T

